package com.Tests;

import android.test.AndroidTestCase;

import com.example.speedwaymanager.CAwayTeam;
import com.example.speedwaymanager.CCoach;
import com.example.speedwaymanager.CHomeTeam;
import com.example.speedwaymanager.CRider;
import com.example.speedwaymanager.CTeam;

/**
 * Created by Lukas on 09.10.13.
 */
public class CCoachTest extends AndroidTestCase {

    private CTeam homeTeam = new CHomeTeam("Leszno");
    private CTeam awayTeam = new CAwayTeam("Leszno");

    protected void setUp() {
        homeTeam.addRiderToTeam(new CRider("0", "Senior5", "Leszno", "1.755", "1.555", "1.564", "SENIOR")); //0
        homeTeam.addRiderToTeam(new CRider("1", "Senior1", "Leszno", "2.425", "2.655", "2.222", "SENIOR")); //1
        homeTeam.addRiderToTeam(new CRider("2", "Senior2", "Leszno", "2.325", "2.555", "2.122", "SENIOR")); //2
        homeTeam.addRiderToTeam(new CRider("3", "Senior4", "Leszno", "2.025", "2.355", "1.322", "SENIOR")); //3
        homeTeam.addRiderToTeam(new CRider("4", "Senior3", "Leszno", "2.225", "2.455", "2.022", "SENIOR")); //4
        homeTeam.addRiderToTeam(new CRider("5", "Senior6", "Leszno", "1.125", "1.155", "1.122", "SENIOR")); //5
        homeTeam.addRiderToTeam(new CRider("0", "Junior1", "Leszno", "1.225", "1.455", "1.022", "JUNIOR")); //6
        homeTeam.addRiderToTeam(new CRider("1", "Junior2", "Leszno", "0.225", "0.455", "0.022", "JUNIOR")); //7
        homeTeam.addRiderToTeam(new CRider("2", "Junior3", "Leszno", "0.125", "0.255", "0.002", "JUNIOR")); //8

        awayTeam.addRiderToTeam(new CRider("0", "Senior5", "Leszno", "1.755", "1.555", "1.564", "SENIOR")); //0
        awayTeam.addRiderToTeam(new CRider("1", "Senior1", "Leszno", "2.425", "2.655", "2.222", "SENIOR")); //1
        awayTeam.addRiderToTeam(new CRider("2", "Senior2", "Leszno", "2.325", "2.555", "2.122", "SENIOR")); //2
        awayTeam.addRiderToTeam(new CRider("3", "Senior4", "Leszno", "2.025", "2.355", "1.322", "SENIOR")); //3
        awayTeam.addRiderToTeam(new CRider("4", "Senior3", "Leszno", "2.225", "2.455", "2.022", "SENIOR")); //4
        awayTeam.addRiderToTeam(new CRider("5", "Senior6", "Leszno", "1.125", "1.155", "1.122", "SENIOR")); //5
        awayTeam.addRiderToTeam(new CRider("0", "Junior1", "Leszno", "1.225", "1.455", "1.022", "JUNIOR")); //6
        awayTeam.addRiderToTeam(new CRider("1", "Junior2", "Leszno", "0.225", "0.455", "0.022", "JUNIOR")); //7
        awayTeam.addRiderToTeam(new CRider("2", "Junior3", "Leszno", "0.125", "0.255", "0.002", "JUNIOR")); //8
    }

    public void testCreateSquadHome() throws Exception {
        CCoach coach = new CCoach("Coach", homeTeam);
        coach.createSquad();
        assertEquals(homeTeam.get_seniorRiders().get(0).toString(), homeTeam.get_riders().get(1).toString());
        assertEquals(homeTeam.get_seniorRiders().get(1).toString(), homeTeam.get_riders().get(2).toString());
        assertEquals(homeTeam.get_seniorRiders().get(2).toString(), homeTeam.get_riders().get(4).toString());
        assertEquals(homeTeam.get_seniorRiders().get(3).toString(), homeTeam.get_riders().get(3).toString());
        assertEquals(homeTeam.get_seniorRiders().get(4).toString(), homeTeam.get_riders().get(0).toString());
        assertEquals(homeTeam.get_seniorRiders().get(5).toString(), homeTeam.get_riders().get(5).toString());
        assertEquals(homeTeam.get_juniorRiders().get(0).toString(), homeTeam.get_riders().get(6).toString());
        assertEquals(homeTeam.get_juniorRiders().get(1).toString(), homeTeam.get_riders().get(7).toString());
        assertEquals(homeTeam.get_juniorRiders().get(2).toString(), homeTeam.get_riders().get(8).toString());

        assertTrue(-1 != homeTeam.get_squad().indexOf(homeTeam.get_riders().get(0)));
        assertTrue(-1 != homeTeam.get_squad().indexOf(homeTeam.get_riders().get(1)));
        assertTrue(-1 != homeTeam.get_squad().indexOf(homeTeam.get_riders().get(2)));
        assertTrue(-1 != homeTeam.get_squad().indexOf(homeTeam.get_riders().get(3)));
        assertTrue(-1 != homeTeam.get_squad().indexOf(homeTeam.get_riders().get(4)));
        assertFalse(-1 != homeTeam.get_squad().indexOf(homeTeam.get_riders().get(5)));
        assertTrue(-1 != homeTeam.get_squad().indexOf(homeTeam.get_riders().get(6)));
        assertTrue(-1 != homeTeam.get_squad().indexOf(homeTeam.get_riders().get(7)));
        assertFalse(-1 != homeTeam.get_squad().indexOf(homeTeam.get_riders().get(8)));
    }

    public void testCreateSquadAway() throws Exception {
        CCoach coach = new CCoach("Coach", awayTeam);
        coach.createSquad();
        assertEquals(awayTeam.get_seniorRiders().get(0).toString(), awayTeam.get_riders().get(1).toString());
        assertEquals(awayTeam.get_seniorRiders().get(1).toString(), awayTeam.get_riders().get(2).toString());
        assertEquals(awayTeam.get_seniorRiders().get(2).toString(), awayTeam.get_riders().get(4).toString());
        assertEquals(awayTeam.get_seniorRiders().get(3).toString(), awayTeam.get_riders().get(0).toString());
        assertEquals(awayTeam.get_seniorRiders().get(4).toString(), awayTeam.get_riders().get(3).toString());
        assertEquals(awayTeam.get_seniorRiders().get(5).toString(), awayTeam.get_riders().get(5).toString());
        assertEquals(awayTeam.get_juniorRiders().get(0).toString(), awayTeam.get_riders().get(6).toString());
        assertEquals(awayTeam.get_juniorRiders().get(1).toString(), awayTeam.get_riders().get(7).toString());
        assertEquals(awayTeam.get_juniorRiders().get(2).toString(), awayTeam.get_riders().get(8).toString());

        assertTrue(-1 != awayTeam.get_squad().indexOf(awayTeam.get_riders().get(0)));
        assertTrue(-1 != awayTeam.get_squad().indexOf(awayTeam.get_riders().get(1)));
        assertTrue(-1 != awayTeam.get_squad().indexOf(awayTeam.get_riders().get(2)));
        assertTrue(-1 != awayTeam.get_squad().indexOf(awayTeam.get_riders().get(3)));
        assertTrue(-1 != awayTeam.get_squad().indexOf(awayTeam.get_riders().get(4)));
        assertFalse(-1 != awayTeam.get_squad().indexOf(awayTeam.get_riders().get(5)));
        assertTrue(-1 != awayTeam.get_squad().indexOf(awayTeam.get_riders().get(6)));
        assertTrue(-1 != awayTeam.get_squad().indexOf(awayTeam.get_riders().get(7)));
        assertFalse(-1 != awayTeam.get_squad().indexOf(awayTeam.get_riders().get(8)));
    }

    public void testAnalyzeChangeRequest() throws Exception {

    }

    public void testSetSquad() throws Exception {

    }
}
